package com.cc.visitor.dao;

import com.cc.visitor.entity.Visit;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author chanchaw
 * @create 2024-09-27 10:21
 */
@Repository
public interface VisitMapper extends BaseMapper<Visit> {
    @Select("call usp_getVisit8DateRange(#{sdate},#{edate})")
    List<Visit> get8DateRange(@Param("sdate")LocalDateTime sdate, @Param("edate")LocalDateTime edate);
    @Select("call usp_getVisitList8DateRangeOpenId(#{unionId},#{sdate},#{edate})")
    List<Visit> get8DateRangeOpenId(@Param("unionId")String unionId,@Param("sdate")LocalDateTime sdate, @Param("edate")LocalDateTime edate);
    // 查询获取指定进度的访单，初次设计为 “门卫管理访单” 表格的数据源
    @Select("call usp_getVisit8Progress(#{progress})")
    List<Visit> getVisit8Progress(@Param("progress")String progress);
    @Select("call usp_getVisit8ProgressAll()")
    List<Visit> getVisit8ProgressAll();
    @Select("call usp_getVisitInProgress()")
    List<Visit> getVisitInProgress();// 获取进行中的访单
    @Select("call usp_getVisitFinishedProgress(#{sdate},#{edate})")
    List<Visit> getVisitFinishedProgress(@Param("sdate") LocalDate sdate, @Param("edate") LocalDate edate);// 获取已完成的访单
    @Select("call usp_getVisitStatistics(#{unionId})")
    List<Visit> getVisitStatistics(@Param("unionId")String unionId);
    // 获取访客制作的最后一单访单
    @Select("call usp_getLastVisit8RealName(#{realName})")
    Visit getLastVisit8RealName(@Param("realName")String realName);
    // 获取指定受访人员制作的最后一单代位申请的访单
    @Select("call usp_getLastSubrogate8RealName(#{realName})")
    Visit getLastSubrogate8RealName(@Param("realName")String realName);
    @Select("call usp_getLastVisit8UnionId(#{unionId},#{subrogate})")
    Visit getLastVisit8UnionId(@Param("unionId")String unionId,@Param("subrogate") Integer subrogate);
    @Select("call usp_getVisit8Id(#{id})")
    Visit getVisit8Id(@Param("id")Integer id);
    @Select("call usp_getVisit8ProgressRecent(#{unionId},#{progress})")
    List<Visit> getVisit8ProgressRecent(@Param("unionId")String unionId, @Param("progress")String progress);
    @Select("call usp_getMyTodayThreeProgressVisit(#{unionId})")
    List<Visit> getMyTodayThreeProgressVisit(@Param("unionId")String unionId);
    @Select("call usp_getVisitWithinTime(#{unionId})")
    List<Visit> getVisitWithinTime(@Param("unionId")String unionId);
    // 自动完工今日之前的 已进场 访单
    @Select("call usp_autoFinishEntered()")
    Integer autoFinishEntered();
    // 获取已审核未进场的前一天的访单，通知受访者
    @Select("call usp_getAuditedUnUse()")
    List<Visit> getAuditedUnUse();
}
